/**
 *@file at_slm332.h
 *@brief This is the header file for at_slm332.c, which is the porting file for the AT command
 *module.
 *@version 1.0
 */

#ifndef AT_SLM332_H
#define AT_SLM332_H

#include "at_slm332_cmd.h"
#include "t_at.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    slm_online = 1,
    slm_power_on,
    slm_power_down,
} at_4G_slm332;

typedef struct {
    char slm_4g_ip[16];  // IP
    char china_network_name[6];  // 注册运营商 移动网络代码 (MNC) 和移动国家代码 (MCC) 的组合：46000
                                 // 460 是中国的国家代码，00 是运营商代码。
    // **46000**：中国移动
    // **46001**：中国联通
    // **46003**：中国电信
    char sim_iccid[25];  // SIM卡的 +QCCID: 89860025128306012474
    char sim_imsi[16];   //
    uint8_t db_singal;   // 信号强度
} slm332_net_info;

typedef enum {
    slm_error = -1,
    slm_powr_open_ok,
    slm_powr_open_fail,
    slm_init_ok,
    slm_send_ok,
    slm_send_fail,
} slm_error_t;

typedef struct {
    uint8_t modbus_replay_buf[256];
    uint8_t modbus_len;
} mqtt_modbus_reply;

typedef struct {
    uint8_t mg_replay_buf[256];
    uint8_t mg_len;
    uint8_t mqttc_id; 
} MQTT_MG_data;

typedef struct slm_mqtt_type {
	  uint8_t slm33_mqtt_id;//MQtt客户端ID号
    char txt[50];
    char client_id[80];  // client_id
    char user_name[80];  // user_name
    char pass_word[80];  // pass_word
    char host[80];       // host
    int port;            // port
    char subtopic[80];
    char pubtopic[80];
    int Qos;  // qos
} slm_mqtt_type_t;

typedef struct slm_platform_type {
    uint8_t p_mode;  // platform 0自己的平台 1阿里云 2移动云 3百度云
} slm_platform_type_t;

typedef struct slm_cfg {
    slm332_net_info slm332_net_info_t;
    at_4G_slm332 slm_status;
    slm_mqtt_type_t smqtt[4];//设计4个mqttClient
	  uint8_t slm33_mqttc_num;  //MQtt客户端ID号客户端数量
} slm_cfg_t;

extern slm_cfg_t slm_cfg;
extern t_at_t *SLM;

slm_error_t slm332_creat(slm_cfg_t *slm_cfg);

uint8_t slm_mqtt_urc_cb(void *Ptx, uint8_t *dataBuf, uint8_t data_len, uint8_t *cmd_UrcString);
///4G发到云端通用接口
slm_error_t pslm_mqtt_send_mqttdata(t_at_t *slm332,
																		slm_cfg_t *slm_cfg,
                                    uint8_t mqttc_id_t,
                                    t_at_urc_callback slm_send_callback, 
																		char *data,
                                    uint16_t datalen) ;
																		
slm_error_t slm_urc_par(t_at_t *slm332, t_at_urc_callback urc_func, uint8_t *URC_info);

slm_error_t mqtt_modbus_urc_decode(t_at_t *slm332, t_at_urc_callback urc_func, uint8_t *URC_info);

slm_error_t mg_send(void *arg, char *data, uint8_t data_len);

uint16_t j_modbus_slave_mg_send_func(void *ctx, void *arg, const uint8_t *req, int req_length);
																		
																		
void mqqtc_sned_other_interface_1(char *data,uint16_t len);
void mqqtc_sned_other_interface_2(char *data,uint16_t len);
void mqqtc_sned_other_interface_3(char *data,uint16_t len);
void mqqtc_sned_other_interface_4(char *data,uint16_t len);
	
																		

#ifdef __cplusplus
}
#endif

#endif /*AT_SLM332_H*/
